import self
from appium.webdriver.common.appiumby import AppiumBy
from time import sleep

from selenium.webdriver.support.wait import WebDriverWait

from common.base_page import BasePage

'''点击聊股-点击消息框-点击收藏按钮'''


class PageCollection(BasePage):
    '''点击聊股'''
    btn_desktop_talk = (AppiumBy.ID, 'com.jhss.youguu:id/btn_desktop_talk')
    '''点击消息框'''
    tv_content = (AppiumBy.ID, 'com.jhss.youguu:id/tv_content')
    # btn_comment = (AppiumBy.ID, 'com.jhss.youguu:id/btn_comment')
    '''点击收藏按钮'''
    favorite = (AppiumBy.ID, 'com.jhss.youguu:id/favorite')
    TextView = (AppiumBy.XPATH, '//android.widget.TextView[@text="收藏"]')

    '''点击发现按钮'''
    btn_desktop_discovery = (AppiumBy.ID, 'com.jhss.youguu:id/btn_desktop_discovery')
    '''置灰头像'''
    head_pic = (AppiumBy.ID, 'com.jhss.youguu:id/head_pic')
    '''点击聊股'''
    lTextView = (AppiumBy.XPATH, '//android.widget.TextView[@text="聊股"]')
    '''点击我的收藏'''
    Tab = (AppiumBy.XPATH, '//android.support.v7.app.ActionBar.Tab[@content-desc="我的收藏"]/android.widget.TextView')
    sTextView = (AppiumBy.ID, '//android.widget.TextView[@text="我的收藏"]')

    '''断言元素（添加成功）'''
    Toast = (AppiumBy.XPATH, '/hierarchy/android.widget.Toast')
    # Toast2 = (AppiumBy.XPATH, '//android.widget.Toast[@text="添加成功"]')

    '''发布帖子第一个昵称'''
    tv_user_name = (AppiumBy.ID, 'com.jhss.youguu:id/tv_user_name')
    '''收藏用户昵称'''
    nickNameView2 = (AppiumBy.ID, 'com.jhss.youguu:id/nickNameView')

    ''''''

    def collection(self):
        '''点击聊股'''
        self.click_ele(self.btn_desktop_talk)
        sleep(2)
        '''点击消息框'''
        self.click_ele(self.tv_content)
        sleep(2)
        '''弹窗提示语'''
        self.tap(1016, 183)
        sleep(2)
        '''点击收藏按钮'''
        self.click_ele(self.TextView)
        sleep(2)
        self.tap(52,88)

    def collection_two(self):
        '''发现'''
        self.click_ele(self.btn_desktop_discovery)
        sleep(2)
        '''点击置灰头像'''
        self.click_ele(self.head_pic)
        sleep(2)
        '''点击聊股'''
        self.click_ele(self.lTextView)
        sleep(2)
        '''点击我的收藏'''
        self.click_ele(self.Tab)
        sleep(2)
